﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<nelech.Models.DBModel.Puzzle>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    חידת השבוע
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
  <div id="left">
 <%--Html.RenderAction("AdvertShow", "Advert", new { id = 7 });%>
  <%Html.RenderAction("AdvertShow", "Advert", new { id = 7 });%>
   <%Html.RenderAction("AdvertShow", "Advert", new { id = 7 });--%>
</div>
<div id="main">
    <h2>
        חידת השבוע</h2>

    <script language="javascript" type="text/javascript">
        function CreateFeedback() {
            var e = document.getElementById("mistoryCreate");
            e.style.display = "block";
        }
        function Close() {
            var e = document.getElementById("mistoryCreate");
            e.style.display = "none";
        }
        function ShowFeedback(i) {
            var e = document.getElementById("mistoryFeedback" + i);
          
            e.style.display =  e.style.display == "block" ? "none" : "block";
         
        }
    </script>

    <% 
        var puzzle = Model.puzzle;
        var feedbacks = Model.listFeedback;
    %>
    <div class="puzzle">
        <% if (puzzle.image.Length > 0)
           { %>
     <p class="ImgPuzzle"><%= Html.ActionLink("<<הבאה", "NextPuzzleTopic", new {id = Model.puzzle.id })%>  <img src="<%= puzzle.image %>" alt="<%= puzzle.title %>" width="400px" /><%= Html.ActionLink("הקודמת>>", "PrePuzzleTopic", new {id = Model.puzzle.id })%></p>
        <%} %>
        <p>
    <%
        if (Model.puzzle.solutionDate < DateTime.Now)
        { %>
    פתרון החידה: 
    <%= puzzle.text %>
    
    <%} %>
  </p>
   <div class="tablePuzzle">
       <span class="puzzelArrow"> <%= Ajax.ActionLink("<<הבאות", "NextPuzzles", new AjaxOptions { UpdateTargetId = "puzzleRange" })%></span>
        <span id="puzzleRange">
            <% Html.RenderAction("NextPuzzles"); %>
        </span>
        <span class="puzzelArrow"> <%= Ajax.ActionLink("הקודמות>>", "PrevPuzzles", new AjaxOptions{UpdateTargetId="puzzleRange" })%></span>
    </div>
    </div>
    <br />
    <br />
    <br />
    <a href="javascript:CreateFeedback()" class="tguva">הוסף תשובה </a>
    <div id="mistoryCreate" style="display: none">
        <% using (Html.BeginForm("CreatePuzzleFeedback", "Forum"))
           {%>
        <fieldset>
            <legend>הוסף תשובה</legend>
            <% Response.Write("<input type=\"hidden\" value=\"" + puzzle.id + "\" name=\"puzzleID\"/>");%>
            <p>
                <span>
                    <label for="name">
                        שם:</label>
                    <%= Html.TextBox("username") %>
                      <%= Html.ValidationMessage("username")%>
                </span><span>
                    <label for="city">
                        עיר:</label>
                    <%= Html.TextBox("city") %>
                      <%= Html.ValidationMessage("city")%>
                </span>
            </p>
            <div>
                <p>
                    <label for="title">
                        כותרת:</label>
                    <%= Html.TextBox("title") %>
                    <%= Html.ValidationMessage("title") %>
                      <%= Html.ValidationMessage("title")%>
                </p>
                <p>
                    <%= Html.TextArea("text", new {cols="45", rows="10" })%>
                    <%= Html.ValidationMessage("text") %>
                </p>
            </div>
            <div class="floatleft">
                <span class="feedbackButton">
                    <input type="submit" value="פרסם" /></span> <span class="feedbackCloseButton">
                        <input type="button" value="סגור" onclick="Close()" /></span>
            </div>
        </fieldset>
        <% } %>
    </div>
    <div class="feedbacks">
        <% var i = 1;
            if (feedbacks != null)
           {%>
        <ol>
            <%foreach (var item in feedbacks)
              {
            %>
            <li>
                <% if (!string.IsNullOrEmpty(item.text))
                   { %>
                <% Response.Write("<a href=\"javascript:ShowFeedback(" + i + ")\">" + item.title + "</a>");
                   }
                   else
                   {%>
                <%= item.title%>
                <span class="littleFont">(ל"ת)</span>
                <%} %>
                <div id="mistoryFeedback<%= i %>" style="display:none">
                    <%= item.text %>
                </div>
                <div>
                    <span class="forumName">
                        <%= item.username%></span> <span class="forumName">
                            <%= item.city%></span>
                    <% i++; %>
                </div>
            </li>
            <%}%></ol>
        <% }%>
    </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="publishTop" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Right" runat="server">
</asp:Content>
